using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Utility;

namespace MKDS_Course_Editor
{
    public partial class CAME : Form
    {
        public nkm.CAMe item = null;
        public CAME(nkm.CAMe i)
        {
            InitializeComponent();
            item = i;
        }

        private void CAME_Load(object sender, EventArgs e)
        {
            numericUpDown1.Value = Convert.ToDecimal(item.X1);
            numericUpDown2.Value = Convert.ToDecimal(item.Y1);
            numericUpDown3.Value = Convert.ToDecimal(item.Z1);
            numericUpDown6.Value = Convert.ToDecimal(item.X2);
            numericUpDown5.Value = Convert.ToDecimal(item.Y2);
            numericUpDown4.Value = Convert.ToDecimal(item.Z2);
            numericUpDown9.Value = Convert.ToDecimal(item.X3);
            numericUpDown8.Value = Convert.ToDecimal(item.Y3);
            numericUpDown7.Value = Convert.ToDecimal(item.Z3);
            textBox1.Text = BitConverter.ToString(item.Setting5).Replace("-","");
            textBox3.Text = BitConverter.ToString(item.Setting4).Replace("-", "");
            textBox2.Text = BitConverter.ToString(item.Setting7).Replace("-", "");
            textBox4.Text = BitConverter.ToString(item.Setting6).Replace("-", "");
        }
        byte[] stringtobyte(string a)
        {
            byte[] buffer;
            int discarded;
            buffer = HexEncoding.GetBytes(a, out discarded);
            return buffer;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            item.X1 = (float)numericUpDown1.Value;
            item.Y1 = (float)numericUpDown2.Value;
            item.Z1 = (float)numericUpDown3.Value;
            item.X2 = (float)numericUpDown6.Value;
            item.Y2 = (float)numericUpDown5.Value;
            item.Z2 = (float)numericUpDown4.Value;
            item.X3 = (float)numericUpDown9.Value;
            item.Y3 = (float)numericUpDown8.Value;
            item.Z3 = (float)numericUpDown7.Value;
            item.Setting5 = stringtobyte(textBox1.Text);
            item.Setting7 = stringtobyte(textBox2.Text);
            item.Setting4 = stringtobyte(textBox3.Text);
            item.Setting6 = stringtobyte(textBox4.Text);
            MKDS_Course_Editor.nkm.item = item;
            this.Close();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
